﻿using HostAssistantBLL;
using HostAssistantCore;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace HostAssistant
{
    public partial class updateftppwd : U1Form
    {
        string id = "";
      
        public updateftppwd(string _id)
        {
            id = _id;
            InitializeComponent();
        }
        private void addsites_Load(object sender, EventArgs e)
        {

            lblname.Text = id;

        }

        #region 返回
        private void simpleButton2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        #endregion

        #region 重置密码

        private void simpleButton3_Click(object sender, EventArgs e)
        {
            
            if (String.IsNullOrWhiteSpace(txtpwd.Text))
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("密码不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
           
            try
            {

            splashScreenManager1.ShowWaitForm();
            splashScreenManager1.SetWaitFormCaption("请等待");
            splashScreenManager1.SetWaitFormDescription("加载中...");


                IISManager a = new IISManager();
                a.PasswordChange(id, txtpwd.Text.Trim());



                string insert_sql = "update Ftpsite  set Pwd=@Pwd where   Name=@Name ";       //插入的SQL语句(带参数)
                Ftpsite Ftpsite = new Ftpsite();

                Ftpsite.Name = id;

                Ftpsite.Pwd = txtpwd.Text.Trim();
                Data<Ftpsite>.GetInstance().Update(insert_sql, Ftpsite);



                splashScreenManager1.CloseWaitForm();
                DevExpress.XtraEditors.XtraMessageBox.Show("成功修改密码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

                this.Close();




                

            }
            catch (Exception ex)
            {
                NLogger.Error(ex.ToString());
                splashScreenManager1.CloseWaitForm();
                DevExpress.XtraEditors.XtraMessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }


        }

        #endregion

    

        private void simpleButton4_Click_1(object sender, EventArgs e)
        {
            txtpwd.Text = Guid.NewGuid().ToString().Substring(0, 6);

        }
    }
}